home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Oh!X 2001 Spring
/
Oh!X 2001 Spring Special CD-ROM (Japan).7z
/
Oh!X 2001 Spring Special CD-ROM (Japan) (Track 1).bin
/
GALAXY
/
ohx5-1
/
d3dx.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2001-01-10
|
3KB
|
153 lines
/*
Oh!X5号
GalaxyKnightsサンプル1
D3DXライブラリ手続き部分
*/
#include "stdafx.h"
#include "ohx5_1.h"
/*
D3DXライブラリを初期化:DX7と8で互換性無しのため、削除
*/
bool init_D3DX()
{
return true;
}
// D3DXデバイスコンテキスト取得
// DirectX8では、DirectX8デバイスコンテキストそのものが無いので削除
// 光源初期化
void init_light()
{
D3DLIGHT8 lg;
ZeroMemory(&lg, sizeof(D3DLIGHT8));
lg.Type = D3DLIGHT_DIRECTIONAL;
lg.Diffuse.r = 1.0f;
lg.Diffuse.g = 1.0f;
lg.Diffuse.b = 1.0f;
lg.Ambient.r = 0.3f;
lg.Ambient.g = 1.0f;
lg.Ambient.b = 2.0f;
lg.Specular.r = 1.0f;
lg.Specular.g = 1.0f;
lg.Specular.b = 1.0f;
lg.Position.x = 1.0f;
lg.Position.y = 9.0f;
lg.Position.z = 1.0f;
lg.Attenuation0 = 1.0f;
lg.Range = (float)sqrt( FLT_MAX );
lpD3DD->SetLight(0, &lg );
lpD3DD->LightEnable(0, TRUE);
}
/*
Direct3Dの動作環境をセットアップする
D3DXヘルパーライブラリとは関係の無い関数になりました。
*/
bool start_D3DX(void)
{
D3DDISPLAYMODE d3ddm;
D3DPRESENT_PARAMETERS d3dpp;
// D3Dオブジェクト確保
if( NULL == (lpD3D = Direct3DCreate8(D3D_SDK_VERSION))) return false;
// ハードウェアチェック
if( FAILED( lpD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) ) return false;
// D3DPRESENT_PARAMETERS メンバの値を初期化
ZeroMemory( &d3dpp,sizeof(d3dpp) );
d3dpp.BackBufferFormat = d3ddm.Format; // 現在のグラフィックモード
d3dpp.BackBufferWidth = 640; // Screen width 640 pixel
d3dpp.BackBufferHeight = 480; // Screen Height 480 pixel
d3dpp.BackBufferCount = 1; // Back surface count
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // Screen Flip logic="Hardware FLIPPING"
d3dpp.Windowed = TRUE; // Full Screen mode
d3dpp.EnableAutoDepthStencil = TRUE; // Stencil buffer disable
d3dpp.AutoDepthStencilFormat = D3DFMT_D16; //
// D3Dデバイスオブジェクト確保
if( FAILED( lpD3D->CreateDevice(
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hwndApp,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&lpD3DD ) ) ) return false;
// Setup render state
lpD3DD->SetRenderState( D3DRS_LIGHTING, TRUE );
lpD3DD->SetRenderState( D3DRS_DITHERENABLE, TRUE );
lpD3DD->SetRenderState( D3DRS_ZENABLE, TRUE );
lpD3DD->SetRenderState( D3DRS_AMBIENT, 0x33333333 );
lpD3DD->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
lpD3DD->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
init_light();
// マテリアル設定
D3DMATERIAL8 material;
ZeroMemory(&material, sizeof(D3DMATERIAL8));
material.Diffuse.r = 1.0f;
material.Diffuse.g = 1.0f;
material.Diffuse.b = 1.0f;
material.Specular.r = 1.0f;
material.Specular.g = 1.0f;
material.Specular.b = 1.0f;
material.Power = 3.0f;
// lpD3DD->SetMaterial(&material);
return true;
}
/*
サーフェイスの開放処理
*/
bool release_surface(void)
{
// xRelease(texp);
return true;
}
/*
Direct3DXの終了処理
*/
bool release_D3DX(void)
{
xRelease(lpD3D);
xRelease(lpD3DD);
// xDelete( surface_format_list );
return true;
}
/*
アプリケーション終了処理
D3DXライブラリの仕様変更で不要になりました。
*/
bool end_application(void)
{
/*
HRESULT hr;
hr = D3DXUninitialize();
if (FAILED(hr)) { return false; }
*/
return true;
}